package packets;

import org.jnetpcap.nio.JBuffer;
import org.jnetpcap.packet.JHeader;

/**
 * Diese Klasse repräsentiert eine LSA Header und definiert Methoden, die die entsprechenden Felder zurückgeben.
 * @author pascal
 *
 */
public class LSA extends JBuffer{


	public LSA() {
		super(20);
	}
	
	public LSA(JHeader peer, int offset, int length){
		super(length);
		this.peer(peer, offset, length);
		
	}

	public int age(){
		return getUShort(0);
	}
	
	public int options(){
		return getUByte(2);
	}
	
	public int type(){
		return getUByte(3);
	}
	
	public long id(){
		return getUInt(4);
	}
	

	public long advertisingRouter(){
		return getUInt(8);	
	}
	

	public long sequenceNumber(){
		return getUInt(12);
	}
	
	
	public long checksum(){
		return getUInt(16);		
	}
	

	public int length(){
		return getUShort(18);
	}
	
	@Override
	public String toString() {
		
		return super.toString();
	}

	
	public void decode() {
		// zum überschreiben
		
	}
	
	@Override
	public boolean equals(Object obj) {
		LSA lsa = (LSA)obj;
		
		if(this.type() == lsa.type() && this.id() == lsa.id() && this.advertisingRouter() == lsa.advertisingRouter()){
			return true;
		}
		else return false;
	}
	
	
	
	
	
	
	

}
